/**
 * File: _document.tsx
 * Project: reactssr
 * Created Date: Wednesday 2018/01/03 13:58:31
 * Author: zhengjiang
 * -----
 * Last Modified: Thursday 2018/01/04 13:46:33
 * Modified By: zhengjiang
 * -----
 * Description: document
 * 
 */
import * as React from 'react';
import Document, { Head, Main, NextScript } from 'next/document';
import { ServerStyleSheet } from 'styled-components';

export default class MyDocument extends Document {
	static getInitialProps({ renderPage }) {
		const sheet = new ServerStyleSheet();
		const page = renderPage((App) => (props) => sheet.collectStyles(<App {...props} />));
		const styleTags = sheet.getStyleElement();
		return { ...page, styleTags };
	}

	render() {
		return (
			<html>
				<Head>
					<title>My page</title>
					<meta charSet="utf-8" />
					<meta name="viewport" content="width=device-width, initial-scale=1" />
					<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/antd/3.0.0/antd.min.css" />
					{this.props.styleTags}
				</Head>
				<body>
					<Main />
					<NextScript />
				</body>
			</html>
		);
	}
}
